<div id="tb<?php echo $uniqid;?>" style="padding:5px">
	<table cellspacing="0" cellpadding="0">
		<tbody>
		<tr>
			<td><a href="javascript:void(0);" onclick="tuikelogReload();" class="l-btn l-btn-small l-btn-plain"><span
					class="l-btn-left l-btn-icon-left"><i class="iconfont icon-shuaxin"></i><span class="l-btn-text">重载</span></span></a></td>
			<td><span style="line-height:30px;">变更日期</span>
				<input id="tuikelogStartOn" style="width:110px" type="text" class="easyui-datebox"> </input>至
				<input id="tuikelogEndOn" style="width:110px" type="text" class="easyui-datebox"> </input>
			</td>
			<td>&nbsp;&nbsp;</td>
			<td>
				<select id="tuikelogKeywordsType" class="forminput inputstyle textbox-text validatebox-text" onchange="keywordsTypeChange(this)" style="width:80px">
					<option value="id">会员ID</option>
					<option value="nickname">会员昵称</option>
					<option value="phone">手机号</option>
				</select></td>
			<td>&nbsp;&nbsp;<input id="tuikelogKeywords" style="width:100px" type="text"
								  class="easyui-input textbox"></td>
			<td><a href="javascript:void(0);" onclick="tuikelogSearch();" class="l-btn l-btn-small l-btn-plain"><span
					class="l-btn-left l-btn-icon-left"><i class="iconfont icon-sousuo"></i><span class="l-btn-text">查询</span></span></a>
			</td>
			<td><a href="javascript:void(0);" onclick="tuikelogReset();" class="l-btn l-btn-small l-btn-plain"><span
					class="l-btn-left l-btn-icon-left"><i class="iconfont icon-shuaxinrefresh39"></i><span
					class="l-btn-text">重置</span></span></a></td>
			<td><a href="javascript:void(0);" onclick="tuikelogExport();" class="l-btn l-btn-small l-btn-plain"><span
					class="l-btn-left l-btn-icon-left"><i class="iconfont icon-xiazai"></i><span
					class="l-btn-text">导出</span></span></a></td>
		</tr>
		</tbody>
	</table>
</div>
<div class="con"  style="-moz-user-select:none;">
	<table id="tuikelog"></table>
</div>
<div id="tuikelogDlg" class="easyui-dialog" style="width:720px; height:520px;" title="信息框" closed="true"></div>
<script>
	var tuikelogExport = function () {
		showLoading('.con');
		$.post('/admin/tuike/levellogsexport', {
			keywordsType: $('#tuikelogKeywordsType').val(),
			keywords: $('#tuikelogKeywords').val(),
			start_on: $('#tuikelogStartOn').val(),
			end_on: $('#tuikelogEndOn').val(),
		}, function (data) {
			hideLoading();
			if (parseInt(data.ret) === 0) {
				$.messager.show({
					title: '提示',
					msg: data.msg,
					timeout: 3000,
					showType: 'slide'
				});
				eventmaterialDownload(data.data);
			} else {
				$.messager.alert('提示', data.msg, 'warning');
			}
		}, 'json').fail((response)=> {
			hideLoading();
			$.messager.alert('提示', response.responseText, 'warning');
		});
	};
	var tuikelogReset = function () {
		$('#tuikelogKeywords').val('');
		$('#tuikelogKeywordsType').val('id');
		$('#tb<?php echo $uniqid;?> #tuikelogStartOn').datebox('setValue', '');
		$('#tb<?php echo $uniqid;?> #tuikelogEndOn').datebox('setValue', '');
		tuikelogSearch();
	};
	var keywordsTypeChange = function (e) {
		let ele = $(e);
		let placeholder = '请输入内容';
		if(ele.val() === 'phone'){
			placeholder = '用户手机号不能少于4位数';
		}
		$('#tb<?php echo $uniqid;?> #tuikelogKeywords').attr('placeholder',placeholder);
	};
	var tuikelogReload = function () {
		$("#tuikelog").datagrid('reload');
	};
	var tuikelogSearch = function () {
		var height = $(window).height() - $(".top").height() - 46;
		var width = $(window).width() - $(".leftmenu").width() - 8;
		$("#tuikelog").datagrid({
			title: '推客级别变更记录',
			width: width,
			height: height,//高度
			singleSelect: true,//如果为true，则只允许选择一行
			striped: true,//是否显示斑马线效果。
			rownumbers: true,//如果为true，则显示一个行号列。
			pagination: true,//是否显示分页
			pageSize: 10,
			pageList: [10, 15, 20, 25],
			method: 'post',
			sortName: 'id',
			sortOrder: 'desc',
			idField: 'id',
			treeField: 'title',
			url: '/admin/tuike/log',
			queryParams: {
				start_on: $('#tuikelogStartOn').val(),
				end_on: $('#tuikelogEndOn').val(),
				keywordsType: $('#tuikelogKeywordsType').val(),
				keywords: $('#tuikelogKeywords').val()
			},
			fitColumns: true,//真正的自动展开/收缩列的大小，以适应网格的宽度，防止水平滚动。
			nowrap: true,//如果为true，则在同一行中显示数据。设置为true可以提高加载性能。 是否换行
			selectOnCheck: false,
			checkOnSelect: true,
			toolbar: '#tb<?php echo $uniqid;?>',
			columns: [[
				{field:'created_at',title:'时间',width:fixWidth(10)},
				{field: 'tuike_id', title: '推客ID', width: fixWidth(5)},
				{
					field: 'tuike_name',
					title: '推客名称',
					width: fixWidth(10),
					formatter: function (value, rowData, rowIndex) {
						return rowData.tuike.realname ? rowData.tuike.realname : rowData.tuike.nickname;
					}
				},
				{
					field: 'tuike_phone',
					title: '推客电话',
					width: fixWidth(10),
					formatter: function (value, rowData, rowIndex) {
						return rowData.tuike.phone ? rowData.tuike.phone : '';
					}
				},
				{field:'before',title:'变更前等级',width:fixWidth(5), align:'center'},
				{field:'after',title:'变更后等级',width:fixWidth(5), align:'center'},
				{field:'remark',title:'备注',width:fixWidth(20)},
				{field:'oper_type',title:'操作人',width:fixWidth(5)},
				{field:'oper_id',title:'操作人ID',width:fixWidth(5),formatter(value){
						return value>0 ? value : '';
					}},
			]]
		});
	};
	onDatagridResize("#tuikelog");
	tuikelogSearch();
</script>
